/**
 * 图表接口实现的实例工厂
 *
 * creatad by qiuwei
 * 2016年05月19日
 */


'use strict'

const chartMap = new Map();
chartMap.set('FixupWorkNewTrend',  require('./charts/FixupWorkNewTrend'));
chartMap.set('FixupWorkCumulativeTrend',  require('./charts/FixupWorkCumulativeTrend'));
chartMap.set('FixupWorkSubjectDistribution',  require('./charts/FixupWorkSubjectDistribution'));
chartMap.set('FixupWorkAreaDistribution',  require('./charts/FixupWorkAreaDistribution'));
chartMap.set('FixupWorkSubmissionRate',  require('./charts/FixupWorkSubmissionRate'));
chartMap.set('FixupWorkQuestionsDistribution', require('./charts/FixupWorkQuestionsDistribution'));
chartMap.set('SubmitWorkNewTrend',  require('./charts/SubmitWorkNewTrend'));
chartMap.set('SubmitWorkCumulativeTrend',  require('./charts/SubmitWorkCumulativeTrend'));
chartMap.set('SubmitWorkSubjectDistribution',  require('./charts/SubmitWorkSubjectDistribution'));
chartMap.set('SubmitWorkAreaDistribution',  require('./charts/SubmitWorkAreaDistribution'));
chartMap.set('ExaminationAnalysisExamFlow', require('./charts/ExaminationAnalysisExamFlow.js'));
chartMap.set('ExaminationAnalysisExamFlowSource', require('./charts/ExaminationAnalysisExamFlowSource.js'));
chartMap.set('ExaminationAnalysisRecommendation', require('./charts/ExaminationAnalysisRecommendation.js'));
chartMap.set('ExaminationAnalysisSourceDistribution', require('./charts/ExaminationAnalysisSourceDistribution.js'));
chartMap.set('ActivityAnalysisInviteTeacher', require('./charts/ActivityAnalysisInviteTeacher.js'));
chartMap.set('ActivityAnalysisTelephone', require('./charts/ActivityAnalysisTelephone.js'));
chartMap.set('ActivityAnalysisInviteCode', require('./charts/ActivityAnalysisInviteCode.js'));
chartMap.set('Practice', require('./charts/Practice.js'));
chartMap.set('Mission', require('./charts/Mission.js'));
chartMap.set('PK', require('./charts/Pk.js'));
chartMap.set('StudentMissionRetained', require('./charts/StudentMissionRetained.js'));

function createDataBuilder(chartName) {
	let chartBuilder = chartMap.get(chartName);

	if (!chartBuilder.API_URL) {
		throw new Error('API_URL can not be empty or null');
	}

	if (!chartBuilder.request) {
		throw new Error('not implement request');
	}

	if (!chartBuilder.response) {
		throw new Error('not implement response')
	}

	return chartBuilder;
}

module.exports = {
	createDataBuilder
}
